package com.csk.zsk.compents.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.csk.zsk.commons.dao.impl.BaseHibernateDao;
import com.csk.zsk.compents.dao.PicnewsDao;
import com.csk.zsk.compents.entity.Picnews;

@Repository
public class PicnewsDaoImpl extends BaseHibernateDao<Picnews, String> implements PicnewsDao {


	@Override
	public Picnews getTop1() {
		List<Picnews> list = this.createQuery("from Picnews picnews where order by picnews.createtime desc").setMaxResults(1).list();
		if(list!=null&&list.size()>0){
			return list.get(0);
		}else{
			return null;
		}
	}

	@Override
	public List<Picnews> getPicnewsByTime(int length) {
		return this.createQuery("from Picnews picnews order by picnews.createtime desc").setMaxResults(length).list();
	}

	@Override
	public List<Picnews> getPicnewsByTypeTime(String type, int length) {
		return this.createQuery("from Picnews picnews where picnews.type=? order by picnews.createtime desc",type).setMaxResults(length).list();
	}

}
